import java.util.Scanner;

public class Main {

    public static int n;
    public static int m;
    public static int[] arr;
    public static int min = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt(); //隔板数
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        dfs(0, 0, new boolean[n - 1]);

        System.out.println(min);

        sc.close();
    }

    /**
     *
     * @param index2 boolean[] 下标
     * @param count 已经插入的隔板数
     */
    public static void dfs(int index2, int count, boolean[] flag) {
        if (index2 == n - 1) {
            if (count == m - 1) {
                int max = 0;
                int sum = arr[0];
                for (int i = 1; i < n; i++) {
                    int index = i;
                    while (index < n && !flag[index - 1]) {
                        sum += arr[index];
                        index++;
                    }
                    max = Math.max(max, sum);
                    if (index >= n) {
                        break;
                    }
                    sum = arr[index];
                    i = index;
                }

                min = Math.min(min, max);
            }
            return;
        }

        for (int i = index2; i < n - 1; i++) {
            //插
            flag[i] = true;
            dfs(i + 1, count + 1, flag);
            //回溯
            flag[i] = false;

            //不插
            dfs(i + 1, count, flag);
        }
    }

    public static void main1(String[] args) {
        int n = 5;
        int m = 2;
        int[] arr = {5,2,1,2,1};
        boolean[] flag = {false, false, false, false, false};

        int max = 0;
        int sum = arr[0];
        for (int i = 1; i < n; i++) {
            int index = i;
            while (index < n && !flag[index - 1]) {
                sum += arr[index];
                index++;
            }
            max = Math.max(max, sum);
            if (index >= n) {
                break;
            }
            sum = arr[index];
            i = index;
        }

        min = Math.min(min, max);

        System.out.println(min);
    }
}
